post 到 return url 的 PayPal 支付变量
PayPal payment variables for post to return url
我目前正在使用 PayPal 通过 API 进行付款,如下所示:
<form id="payment" method="post" action= "https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="business" value="xxx@yahoo.com">
<input type="hidden" name="item_name" value="Order">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="return" value="http://www.example.com/callback" />
<input type='hidden' name='rm' value='2'>
</form>
如 https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HI0709B 所述,rm
设置为 2 以在付款过程后对 return url 使用 POST
方法。
但是,return POST
变量没有详细描述,我从 chrome 得到了一些变量,如:
mc_gross:1.00
mc_currency:USD
这很容易理解。但变量如:
verify_sign:AIcINKz4gusKUvaiOqo3JiAvlEBFA-7ApBee-2bb5OtUUM5RhVUumd84
auth:AEH3nN1f7cUPFUFS4wPBRv6gOw6CV0BppygOu6y-vRHspA3a-ae-y2BnH1tQds1bwOG4EFqxZrcgNxLXKZdsDWg
我没弄明白是什么意思。可能这应该像加密或校验和?如果是,我如何检查这些 return 变量的有效性?
这是贝宝付款方式的示例。
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [self.paymentAmount decimalNumberByRoundingAccordingToBehavior:roundUp];
payment.currencyCode = @"USD";
self.PayPalReceiverEmail = [[self.photo objectForKey:kPAPPhotoUserKey] objectForKey:kPayPalReceiverEmailKey];
payment.shortDescription = self.PayPalReceiverEmail;
if (([[NSDecimalNumber notANumber] isEqualToNumber:payment.amount] ) ) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please enter a valid amount" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
[alert show];
}
else {
if (!payment.processable)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Payment cannot be processed. Please contact technical support." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
[alert show];
}
else
{
// Any customer identifier that you have will work here. Do NOT use a device- or
// hardware-based identifier.
//self.customerId = @"user-12345";
self.customerId = [PFUser currentUser].objectId;
// Set the environment:
// - For live charges, use PayPalEnvironmentProduction (default).
// - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
// - For testing, use PayPalEnvironmentNoNetwork.
[PayPalPaymentViewController setEnvironment:self.environment];
if (self.PayPalReceiverEmail && self.PayPalReceiverEmail.length >0 )
{
PayPalPaymentViewController *paymentViewController;
if (self.PayPalClientId && self.PayPalClientId.length > 0)
{
paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:self.PayPalClientId
receiverEmail:self.PayPalReceiverEmail
payerId:self.customerId
payment:payment
delegate:self];
paymentViewController.hideCreditCardButton = !self.acceptCreditCards;
}
else
{
paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:kPayPalClientId
receiverEmail:self.PayPalReceiverEmail
payerId:self.customerId
payment:payment
delegate:self];
paymentViewController.hideCreditCardButton = YES;
}
// Setting the languageOrLocale property is optional.
//
// If you do not set languageOrLocale, then the PayPalPaymentViewController will present
// its user interface according to the device's current language setting.
//
// Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or
// locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController
// to use that language/locale.
// For full details, including a list of available languages and locales, see PayPalPaymentViewController.h.
paymentViewController.languageOrLocale = @"en";
[self presentViewController:paymentViewController animated:YES completion:nil];
我目前正在使用 PayPal 通过 API 进行付款,如下所示:
<form id="payment" method="post" action= "https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="business" value="xxx@yahoo.com">
<input type="hidden" name="item_name" value="Order">
<input type="hidden" name="amount" value="1.00">
<input type="hidden" name="return" value="http://www.example.com/callback" />
<input type='hidden' name='rm' value='2'>
</form>
如 https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HI0709B 所述,rm
设置为 2 以在付款过程后对 return url 使用 POST
方法。
但是,return POST
变量没有详细描述,我从 chrome 得到了一些变量,如:
mc_gross:1.00
mc_currency:USD
这很容易理解。但变量如:
verify_sign:AIcINKz4gusKUvaiOqo3JiAvlEBFA-7ApBee-2bb5OtUUM5RhVUumd84
auth:AEH3nN1f7cUPFUFS4wPBRv6gOw6CV0BppygOu6y-vRHspA3a-ae-y2BnH1tQds1bwOG4EFqxZrcgNxLXKZdsDWg
我没弄明白是什么意思。可能这应该像加密或校验和?如果是,我如何检查这些 return 变量的有效性?
这是贝宝付款方式的示例。
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [self.paymentAmount decimalNumberByRoundingAccordingToBehavior:roundUp];
payment.currencyCode = @"USD";
self.PayPalReceiverEmail = [[self.photo objectForKey:kPAPPhotoUserKey] objectForKey:kPayPalReceiverEmailKey];
payment.shortDescription = self.PayPalReceiverEmail;
if (([[NSDecimalNumber notANumber] isEqualToNumber:payment.amount] ) ) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please enter a valid amount" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
[alert show];
}
else {
if (!payment.processable)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Payment cannot be processed. Please contact technical support." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
[alert show];
}
else
{
// Any customer identifier that you have will work here. Do NOT use a device- or
// hardware-based identifier.
//self.customerId = @"user-12345";
self.customerId = [PFUser currentUser].objectId;
// Set the environment:
// - For live charges, use PayPalEnvironmentProduction (default).
// - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
// - For testing, use PayPalEnvironmentNoNetwork.
[PayPalPaymentViewController setEnvironment:self.environment];
if (self.PayPalReceiverEmail && self.PayPalReceiverEmail.length >0 )
{
PayPalPaymentViewController *paymentViewController;
if (self.PayPalClientId && self.PayPalClientId.length > 0)
{
paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:self.PayPalClientId
receiverEmail:self.PayPalReceiverEmail
payerId:self.customerId
payment:payment
delegate:self];
paymentViewController.hideCreditCardButton = !self.acceptCreditCards;
}
else
{
paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:kPayPalClientId
receiverEmail:self.PayPalReceiverEmail
payerId:self.customerId
payment:payment
delegate:self];
paymentViewController.hideCreditCardButton = YES;
}
// Setting the languageOrLocale property is optional.
//
// If you do not set languageOrLocale, then the PayPalPaymentViewController will present
// its user interface according to the device's current language setting.
//
// Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or
// locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController
// to use that language/locale.
// For full details, including a list of available languages and locales, see PayPalPaymentViewController.h.
paymentViewController.languageOrLocale = @"en";
[self presentViewController:paymentViewController animated:YES completion:nil];